<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <button onclick="location.replace('https://www.nankai.edu.cn')">Click me to visit NKU</button>
  <script>
    // Create anchor element and use href property for the purpose of this example
    // A more correct alternative is to browse to the URL and use document.location or window.location
    var url = document.createElement("a");
    url.href =
      "https://developer.mozilla.org/en-US/search?q=URL#search-results-close-container";
    console.log(url.href); // https://developer.mozilla.org/en-US/search?q=URL#search-results-close-container
    console.log(url.protocol); // https:
    console.log(url.host); // developer.mozilla.org
    console.log(url.hostname); // developer.mozilla.org
    console.log(url.port); // (blank - https assumes port 443)
    console.log(url.pathname); // /en-US/search
    console.log(url.search); // ?q=URL
    console.log(url.hash); // #search-results-close-container
    console.log(url.origin); // https://developer.mozilla.org
    
  </script>
</body>

</html>